<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">

<title>class Gem::Command - rubygems: Ruby Standard Library Documentation</title>


<script src="../js/navigation.js" defer></script>
<script src="../js/search.js" defer></script>
<script src="../js/search_index.js" defer></script>
<script src="../js/searcher.js" defer></script>
<script src="../js/darkfish.js" defer></script>

<script src="../js/jquery-3.2.0.min.js"></script>

<script src="../js/vue.min.js"></script>
<script src="../js/js.cookie.min.js"></script>

<link href="../css/fonts.css" rel="stylesheet">
<link id='rdoccss' href="../css/rdoc.css" rel="stylesheet">
<link href="../css/carbon17.css" rel="stylesheet">

<script type="text/javascript">
  var rdoc_rel_prefix = "../";
  var index_rel_prefix = "../";
  var darkModeCsseHref = "../css/rdoc-dm.css"
  var defaultModeCssHref = "../css/rdoc.css"
  // var cssDarkmode = Cookies.get('darkmode');
  
  if( Cookies.get("darkmode") == "true") {
	$('#rdoccss').attr("href", darkModeCsseHref);
}

//  https://cssdeck.com/blog/simple-jquery-stylesheet-switcher/

document.write('<style type="text/css">body{display:none}</style>');

</script>


</head>
<body id="top" role="document" class="class">
  <!-- this is class.html -->

  <div id='actionbar' >
    <div class='wrapper mdiv'>
      <ul class='grids g0'></ul>
    </div> 
    <!-- VERSION HEADER for 3.3.0.preview2 NOT FOUND -->
  </div> <!-- end action bar -->

  <div class='wrapper hdiv'>

    


    <nav id='vapp' role="navigation">
    <div id="project-navigation">
      <div id="home-section" role="region" title="Quick navigation" class="nav-section">
  <h2><a href="../index.html" rel="home">Home</a></h2>

  <div id="table-of-contents-navigation"  >
    <a href="../table_of_contents.html#pages">Pages</a>
    <a href="../table_of_contents.html#classes">Classes</a>
    <a href="../table_of_contents.html#methods">Methods</a>
  </div>
</div>

      <div id="search-section" role="search" class="project-section initially-hidden">
  <form action="#" method="get" accept-charset="utf-8">
    <div id="search-field-wrapper">
      <input id="search-field" role="combobox" aria-label="Search"
             aria-autocomplete="list" aria-controls="search-results"
             type="text" name="search" placeholder="Search" spellcheck="false"
             title="Type to search, Up and Down to navigate, Enter to load">
    </div>

    <ul id="search-results" aria-label="Search Results"
        aria-busy="false" aria-expanded="false"
        aria-atomic="false" class="initially-hidden"></ul>
  </form>
</div>

    </div>


    

    <button id='toggleThing' @click="toggleNav()" >Show/hide navigation</button>
    <div :class="isOpen ? 'block' : 'hidden' " id='toggleMe'>
      <div id="class-metadata">
        
        
<div id="parent-class-section" class="nav-section">
  <h3>Parent</h3>

  <p class="link">Object
</div>

        
<div id="includes-section" class="nav-section">
  <h3>Included Modules</h3>

  <ul class="link-list">
    <li><a class="include" href="UserInteraction.html">Gem::UserInteraction</a>
  </ul>
</div>

        
        
<!-- Method Quickref -->
<div id="method-list-section" class="nav-section">
  <h3>Methods</h3>

  <ul class="link-list" role="directory">
    <li ><a href="#method-c-add_common_option">::add_common_option</a>
    <li ><a href="#method-c-add_specific_extra_args">::add_specific_extra_args</a>
    <li ><a href="#method-c-build_args">::build_args</a>
    <li ><a href="#method-c-build_args-3D">::build_args=</a>
    <li ><a href="#method-c-common_options">::common_options</a>
    <li ><a href="#method-c-extra_args">::extra_args</a>
    <li ><a href="#method-c-extra_args-3D">::extra_args=</a>
    <li ><a href="#method-c-new">::new</a>
    <li ><a href="#method-c-specific_extra_args">::specific_extra_args</a>
    <li ><a href="#method-c-specific_extra_args_hash">::specific_extra_args_hash</a>
    <li ><a href="#method-i-add_extra_args">#add_extra_args</a>
    <li ><a href="#method-i-add_option">#add_option</a>
    <li ><a href="#method-i-add_parser_run_info">#add_parser_run_info</a>
    <li ><a href="#method-i-arguments">#arguments</a>
    <li ><a href="#method-i-begins-3F">#begins?</a>
    <li ><a href="#method-i-check_deprecated_options">#check_deprecated_options</a>
    <li ><a href="#method-i-configure_options">#configure_options</a>
    <li ><a href="#method-i-create_option_parser">#create_option_parser</a>
    <li ><a href="#method-i-defaults_str">#defaults_str</a>
    <li ><a href="#method-i-deprecate_option">#deprecate_option</a>
    <li ><a href="#method-i-deprecated-3F">#deprecated?</a>
    <li ><a href="#method-i-description">#description</a>
    <li ><a href="#method-i-execute">#execute</a>
    <li ><a href="#method-i-get_all_gem_names">#get_all_gem_names</a>
    <li ><a href="#method-i-get_all_gem_names_and_versions">#get_all_gem_names_and_versions</a>
    <li ><a href="#method-i-get_one_gem_name">#get_one_gem_name</a>
    <li ><a href="#method-i-get_one_optional_argument">#get_one_optional_argument</a>
    <li ><a href="#method-i-handle_options">#handle_options</a>
    <li ><a href="#method-i-handles-3F">#handles?</a>
    <li ><a href="#method-i-invoke">#invoke</a>
    <li ><a href="#method-i-invoke_with_build_args">#invoke_with_build_args</a>
    <li ><a href="#method-i-merge_options">#merge_options</a>
    <li ><a href="#method-i-option_is_deprecated-3F">#option_is_deprecated?</a>
    <li ><a href="#method-i-parser">#parser</a>
    <li ><a href="#method-i-remove_option">#remove_option</a>
    <li ><a href="#method-i-show_help">#show_help</a>
    <li ><a href="#method-i-show_lookup_failure">#show_lookup_failure</a>
    <li ><a href="#method-i-usage">#usage</a>
    <li ><a href="#method-i-when_invoked">#when_invoked</a>
    <li ><a href="#method-i-wrap">#wrap</a>
  </ul>
</div>

      </div>
     </div>
    </nav>


    <div id='extraz'><div class='adzbox-index'  >
      
     </div>         
    </div>

    <main role="main" aria-labelledby="class-Gem::Command">
    <h1 id="class-Gem::Command" class="class">
      class Gem::Command
    </h1>

    <section class="description">
    
<p>Base class for all <a href="../Gem.html"><code>Gem</code></a> commands.  When creating a new gem command, define initialize, <a href="Command.html#method-i-execute"><code>execute</code></a>, <a href="Command.html#method-i-arguments"><code>arguments</code></a>, <a href="Command.html#method-i-defaults_str"><code>defaults_str</code></a>, <a href="Command.html#method-i-description"><code>description</code></a> and <a href="Command.html#method-i-usage"><code>usage</code></a> (as appropriate).  See the above mentioned methods for details.</p>

<p>A very good example to look at is <a href="Commands/ContentsCommand.html"><code>Gem::Commands::ContentsCommand</code></a></p>

    </section>

      <section id="5Buntitled-5D" class="documentation-section">



        <section class="attribute-method-details" class="method-section">
        <header>
        <h3>Attributes</h3>
        </header>

          <div id="attribute-i-command" class="method-detail">
            <div class="method-heading attribute-method-heading">
              <span class="method-name">command</span><span
                class="attribute-access-type">[R]</span>
            </div>

            <div class="method-description">
              <p>The name of the command.</p>
              </div>
            </div>
          <div id="attribute-i-defaults" class="method-detail">
            <div class="method-heading attribute-method-heading">
              <span class="method-name">defaults</span><span
                class="attribute-access-type">[RW]</span>
            </div>

            <div class="method-description">
              <p>The default options for the command.</p>
              </div>
            </div>
          <div id="attribute-i-options" class="method-detail">
            <div class="method-heading attribute-method-heading">
              <span class="method-name">options</span><span
                class="attribute-access-type">[R]</span>
            </div>

            <div class="method-description">
              <p>The options for the command.</p>
              </div>
            </div>
          <div id="attribute-i-program_name" class="method-detail">
            <div class="method-heading attribute-method-heading">
              <span class="method-name">program_name</span><span
                class="attribute-access-type">[RW]</span>
            </div>

            <div class="method-description">
              <p>The name of the command for command-line invocation.</p>
              </div>
            </div>
          <div id="attribute-i-summary" class="method-detail">
            <div class="method-heading attribute-method-heading">
              <span class="method-name">summary</span><span
                class="attribute-access-type">[RW]</span>
            </div>

            <div class="method-description">
              <p>A short description of the command.</p>
              </div>
            </div>
            </section>


                <section id="public-class-5Buntitled-5D-method-details" class="method-section">
                <header>
                <h3>Public Class Methods</h3>
                </header>

                  <div id="method-c-add_common_option" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">add_common_option</span><span
                                class="method-args">(*args, &amp;handler)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="add_common_option-source">
            <pre><span class="ruby-comment"># File rubygems/command.rb, line 65</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">add_common_option</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">handler</span>)
  <span class="ruby-constant">Gem</span><span class="ruby-operator">::</span><span class="ruby-constant">Command</span>.<span class="ruby-identifier">common_options</span> <span class="ruby-operator">&lt;&lt;</span> [<span class="ruby-identifier">args</span>, <span class="ruby-identifier">handler</span>]
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-add_specific_extra_args" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">add_specific_extra_args</span><span
                                class="method-args">(cmd,args)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Add a list of extra arguments for the given command.  <code>args</code> may be an array or a string to be split on white space.</p>

                              <div class="method-source-code" id="add_specific_extra_args-source">
            <pre><span class="ruby-comment"># File rubygems/command.rb, line 94</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">add_specific_extra_args</span>(<span class="ruby-identifier">cmd</span>,<span class="ruby-identifier">args</span>)
  <span class="ruby-identifier">args</span> = <span class="ruby-identifier">args</span>.<span class="ruby-identifier">split</span>(<span class="ruby-regexp">/\s+/</span>) <span class="ruby-keyword">if</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">is_a?</span> <span class="ruby-constant">String</span>
  <span class="ruby-identifier">specific_extra_args_hash</span>[<span class="ruby-identifier">cmd</span>] = <span class="ruby-identifier">args</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-build_args" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">build_args</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Arguments used when building gems</p>

                              <div class="method-source-code" id="build_args-source">
            <pre><span class="ruby-comment"># File rubygems/command.rb, line 53</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">build_args</span>
  <span class="ruby-ivar">@build_args</span> <span class="ruby-operator">||=</span> []
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-build_args-3D" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">build_args=</span><span
                                class="method-args">(value)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="build_args-3D-source">
            <pre><span class="ruby-comment"># File rubygems/command.rb, line 57</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">build_args=</span>(<span class="ruby-identifier">value</span>)
  <span class="ruby-ivar">@build_args</span> = <span class="ruby-identifier">value</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-common_options" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">common_options</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="common_options-source">
            <pre><span class="ruby-comment"># File rubygems/command.rb, line 61</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">common_options</span>
  <span class="ruby-ivar">@common_options</span> <span class="ruby-operator">||=</span> []
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-extra_args" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">extra_args</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="extra_args-source">
            <pre><span class="ruby-comment"># File rubygems/command.rb, line 69</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">extra_args</span>
  <span class="ruby-ivar">@extra_args</span> <span class="ruby-operator">||=</span> []
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-extra_args-3D" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">extra_args=</span><span
                                class="method-args">(value)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="extra_args-3D-source">
            <pre><span class="ruby-comment"># File rubygems/command.rb, line 73</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">extra_args=</span>(<span class="ruby-identifier">value</span>)
  <span class="ruby-keyword">case</span> <span class="ruby-identifier">value</span>
  <span class="ruby-keyword">when</span> <span class="ruby-constant">Array</span>
    <span class="ruby-ivar">@extra_args</span> = <span class="ruby-identifier">value</span>
  <span class="ruby-keyword">when</span> <span class="ruby-constant">String</span>
    <span class="ruby-ivar">@extra_args</span> = <span class="ruby-identifier">value</span>.<span class="ruby-identifier">split</span>(<span class="ruby-string">&quot; &quot;</span>)
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-new" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">new</span><span
                                class="method-args">(command, summary=nil, defaults={})</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Initializes a generic gem command named <code>command</code>.  <code>summary</code> is a short description displayed in ‘gem help commands`.  <code>defaults</code> are the default options.  Defaults should be mirrored in <a href="Command.html#method-i-defaults_str"><code>defaults_str</code></a>, unless there are none.</p>

<p>When defining a new command subclass, use <a href="Command.html#method-i-add_option"><code>add_option</code></a> to add command-line switches.</p>

<p>Unhandled arguments (gem names, files, etc.) are left in <code>options[:args]</code>.</p>

                              <div class="method-source-code" id="new-source">
            <pre><span class="ruby-comment"># File rubygems/command.rb, line 120</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">initialize</span>(<span class="ruby-identifier">command</span>, <span class="ruby-identifier">summary</span>=<span class="ruby-keyword">nil</span>, <span class="ruby-identifier">defaults</span>={})
  <span class="ruby-ivar">@command</span> = <span class="ruby-identifier">command</span>
  <span class="ruby-ivar">@summary</span> = <span class="ruby-identifier">summary</span>
  <span class="ruby-ivar">@program_name</span> = <span class="ruby-node">&quot;gem #{command}&quot;</span>
  <span class="ruby-ivar">@defaults</span> = <span class="ruby-identifier">defaults</span>
  <span class="ruby-ivar">@options</span> = <span class="ruby-identifier">defaults</span>.<span class="ruby-identifier">dup</span>
  <span class="ruby-ivar">@option_groups</span> = <span class="ruby-constant">Hash</span>.<span class="ruby-identifier">new</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">h</span>,<span class="ruby-identifier">k</span><span class="ruby-operator">|</span> <span class="ruby-identifier">h</span>[<span class="ruby-identifier">k</span>] = [] }
  <span class="ruby-ivar">@deprecated_options</span> = { <span class="ruby-identifier">command</span> <span class="ruby-operator">=&gt;</span> {} }
  <span class="ruby-ivar">@parser</span> = <span class="ruby-keyword">nil</span>
  <span class="ruby-ivar">@when_invoked</span> = <span class="ruby-keyword">nil</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-specific_extra_args" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">specific_extra_args</span><span
                                class="method-args">(cmd)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Return an array of extra arguments for the command.  The extra arguments come from the gem configuration file read at program startup.</p>

                              <div class="method-source-code" id="specific_extra_args-source">
            <pre><span class="ruby-comment"># File rubygems/command.rb, line 86</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">specific_extra_args</span>(<span class="ruby-identifier">cmd</span>)
  <span class="ruby-identifier">specific_extra_args_hash</span>[<span class="ruby-identifier">cmd</span>]
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-specific_extra_args_hash" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">specific_extra_args_hash</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Accessor for the specific extra args hash (self initializing).</p>

                              <div class="method-source-code" id="specific_extra_args_hash-source">
            <pre><span class="ruby-comment"># File rubygems/command.rb, line 102</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">specific_extra_args_hash</span>
  <span class="ruby-ivar">@specific_extra_args_hash</span> <span class="ruby-operator">||=</span> <span class="ruby-constant">Hash</span>.<span class="ruby-identifier">new</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">h</span>,<span class="ruby-identifier">k</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">h</span>[<span class="ruby-identifier">k</span>] = <span class="ruby-constant">Array</span>.<span class="ruby-identifier">new</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                          </section>

                <section id="public-instance-5Buntitled-5D-method-details" class="method-section">
                <header>
                <h3>Public Instance Methods</h3>
                </header>

                  <div id="method-i-add_extra_args" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">add_extra_args</span><span
                                class="method-args">(args)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Adds extra args from ~/.gemrc</p>

                              <div class="method-source-code" id="add_extra_args-source">
            <pre><span class="ruby-comment"># File rubygems/command.rb, line 451</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">add_extra_args</span>(<span class="ruby-identifier">args</span>)
  <span class="ruby-identifier">result</span> = []

  <span class="ruby-identifier">s_extra</span> = <span class="ruby-constant">Gem</span><span class="ruby-operator">::</span><span class="ruby-constant">Command</span>.<span class="ruby-identifier">specific_extra_args</span>(<span class="ruby-ivar">@command</span>)
  <span class="ruby-identifier">extra</span> = <span class="ruby-constant">Gem</span><span class="ruby-operator">::</span><span class="ruby-constant">Command</span>.<span class="ruby-identifier">extra_args</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">s_extra</span>

  <span class="ruby-keyword">until</span> <span class="ruby-identifier">extra</span>.<span class="ruby-identifier">empty?</span> <span class="ruby-keyword">do</span>
    <span class="ruby-identifier">ex</span> = []
    <span class="ruby-identifier">ex</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">extra</span>.<span class="ruby-identifier">shift</span>
    <span class="ruby-identifier">ex</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">extra</span>.<span class="ruby-identifier">shift</span> <span class="ruby-keyword">if</span> <span class="ruby-regexp">/^[^-]/</span>.<span class="ruby-identifier">match?</span>(<span class="ruby-identifier">extra</span>.<span class="ruby-identifier">first</span>.<span class="ruby-identifier">to_s</span>)
    <span class="ruby-identifier">result</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">ex</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">handles?</span>(<span class="ruby-identifier">ex</span>)
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">result</span>.<span class="ruby-identifier">flatten!</span>
  <span class="ruby-identifier">result</span>.<span class="ruby-identifier">concat</span>(<span class="ruby-identifier">args</span>)
  <span class="ruby-identifier">result</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-add_option" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">add_option</span><span
                                class="method-args">(*opts) { |value, options| ... }</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Add a command-line option and handler to the command.</p>

<p>See <a href="OptionParser.html#method-i-make_switch"><code>Gem::OptionParser#make_switch</code></a> for an explanation of <code>opts</code>.</p>

<p><code>handler</code> will be called with two values, the value of the argument and the options hash.</p>

<p>If the first argument of <a href="Command.html#method-i-add_option"><code>add_option</code></a> is a Symbol, it’s used to group options in output.  See ‘gem help list` for an example.</p>

                              <div class="method-source-code" id="add_option-source">
            <pre><span class="ruby-comment"># File rubygems/command.rb, line 358</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">add_option</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">opts</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">handler</span>) <span class="ruby-comment"># :yields: value, options</span>
  <span class="ruby-identifier">group_name</span> = <span class="ruby-constant">Symbol</span> <span class="ruby-operator">===</span> <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">first</span> <span class="ruby-operator">?</span> <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">shift</span> <span class="ruby-operator">:</span> <span class="ruby-value">:options</span>

  <span class="ruby-identifier">raise</span> <span class="ruby-string">&quot;Do not pass an empty string in opts&quot;</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-string">&quot;&quot;</span>)

  <span class="ruby-ivar">@option_groups</span>[<span class="ruby-identifier">group_name</span>] <span class="ruby-operator">&lt;&lt;</span> [<span class="ruby-identifier">opts</span>, <span class="ruby-identifier">handler</span>]
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-arguments" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">arguments</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Override to provide details of the arguments a command takes.  It should return a left-justified string, one argument per line.</p>

<p>For example:</p>

<pre class="ruby"><span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">usage</span>
  <span class="ruby-node">&quot;#{program_name} FILE [FILE ...]&quot;</span>
<span class="ruby-keyword">end</span>

<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">arguments</span>
  <span class="ruby-string">&quot;FILE          name of file to find&quot;</span>
<span class="ruby-keyword">end</span>
</pre>

                              <div class="method-source-code" id="arguments-source">
            <pre><span class="ruby-comment"># File rubygems/command.rb, line 258</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">arguments</span>
  <span class="ruby-string">&quot;&quot;</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-begins-3F" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">begins?</span><span
                                class="method-args">(long, short)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>True if <code>long</code> begins with the characters from <code>short</code>.</p>

                              <div class="method-source-code" id="begins-3F-source">
            <pre><span class="ruby-comment"># File rubygems/command.rb, line 135</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">begins?</span>(<span class="ruby-identifier">long</span>, <span class="ruby-identifier">short</span>)
  <span class="ruby-keyword">return</span> <span class="ruby-keyword">false</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">short</span>.<span class="ruby-identifier">nil?</span>
  <span class="ruby-identifier">long</span>[<span class="ruby-value">0</span>, <span class="ruby-identifier">short</span>.<span class="ruby-identifier">length</span>] <span class="ruby-operator">==</span> <span class="ruby-identifier">short</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-check_deprecated_options" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">check_deprecated_options</span><span
                                class="method-args">(options)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="check_deprecated_options-source">
            <pre><span class="ruby-comment"># File rubygems/command.rb, line 397</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">check_deprecated_options</span>(<span class="ruby-identifier">options</span>)
  <span class="ruby-identifier">options</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">option</span><span class="ruby-operator">|</span>
    <span class="ruby-keyword">next</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">option_is_deprecated?</span>(<span class="ruby-identifier">option</span>)
    <span class="ruby-identifier">deprecation</span> = <span class="ruby-ivar">@deprecated_options</span>[<span class="ruby-identifier">command</span>][<span class="ruby-identifier">option</span>]
    <span class="ruby-identifier">version_to_expire</span> = <span class="ruby-identifier">deprecation</span>[<span class="ruby-string">&quot;rg_version_to_expire&quot;</span>]

    <span class="ruby-identifier">deprecate_option_msg</span> = <span class="ruby-keyword">if</span> <span class="ruby-identifier">version_to_expire</span>
      <span class="ruby-node">&quot;The \&quot;#{option}\&quot; option has been deprecated and will be removed in Rubygems #{version_to_expire}.&quot;</span>
    <span class="ruby-keyword">else</span>
      <span class="ruby-node">&quot;The \&quot;#{option}\&quot; option has been deprecated and will be removed in future versions of Rubygems.&quot;</span>
    <span class="ruby-keyword">end</span>

    <span class="ruby-identifier">extra_msg</span> = <span class="ruby-identifier">deprecation</span>[<span class="ruby-string">&quot;extra_msg&quot;</span>]

    <span class="ruby-identifier">deprecate_option_msg</span> <span class="ruby-operator">+=</span> <span class="ruby-node">&quot; #{extra_msg}&quot;</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">extra_msg</span>

    <span class="ruby-identifier">alert_warning</span>(<span class="ruby-identifier">deprecate_option_msg</span>)
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-defaults_str" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">defaults_str</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Override to display the default values of the command options. (similar to <code>arguments</code>, but displays the default values).</p>

<p>For example:</p>

<pre>def defaults_str
  --no-gems-first --no-all
end</pre>

                              <div class="method-source-code" id="defaults_str-source">
            <pre><span class="ruby-comment"># File rubygems/command.rb, line 272</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">defaults_str</span>
  <span class="ruby-string">&quot;&quot;</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-deprecate_option" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">deprecate_option</span><span
                                class="method-args">(name, version: nil, extra_msg: nil)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Mark a command-line option as deprecated, and optionally specify a deprecation horizon.</p>

<p>Note that with the current implementation, every version of the option needs to be explicitly deprecated, so to deprecate an option defined as</p>

<pre class="ruby"><span class="ruby-identifier">add_option</span>(<span class="ruby-string">&#39;-t&#39;</span>, <span class="ruby-string">&#39;--[no-]test&#39;</span>, <span class="ruby-string">&#39;Set test mode&#39;</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">value</span>, <span class="ruby-identifier">options</span><span class="ruby-operator">|</span>
  <span class="ruby-comment"># ... stuff ...</span>
<span class="ruby-keyword">end</span>
</pre>

<p>you would need to explicitly add a call to ‘deprecate_option` for every version of the option you want to deprecate, like</p>

<pre class="ruby"><span class="ruby-identifier">deprecate_option</span>(<span class="ruby-string">&#39;-t&#39;</span>)
<span class="ruby-identifier">deprecate_option</span>(<span class="ruby-string">&#39;--test&#39;</span>)
<span class="ruby-identifier">deprecate_option</span>(<span class="ruby-string">&#39;--no-test&#39;</span>)
</pre>

                              <div class="method-source-code" id="deprecate_option-source">
            <pre><span class="ruby-comment"># File rubygems/command.rb, line 393</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">deprecate_option</span>(<span class="ruby-identifier">name</span>, <span class="ruby-value">version:</span> <span class="ruby-keyword">nil</span>, <span class="ruby-value">extra_msg:</span> <span class="ruby-keyword">nil</span>)
  <span class="ruby-ivar">@deprecated_options</span>[<span class="ruby-identifier">command</span>].<span class="ruby-identifier">merge!</span>({ <span class="ruby-identifier">name</span> <span class="ruby-operator">=&gt;</span> { <span class="ruby-string">&quot;rg_version_to_expire&quot;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-identifier">version</span>, <span class="ruby-string">&quot;extra_msg&quot;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-identifier">extra_msg</span> } })
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-deprecated-3F" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">deprecated?</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="deprecated-3F-source">
            <pre><span class="ruby-comment"># File rubygems/command.rb, line 469</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">deprecated?</span>
  <span class="ruby-keyword">false</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-description" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">description</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Override to display a longer description of what this command does.</p>

                              <div class="method-source-code" id="description-source">
            <pre><span class="ruby-comment"># File rubygems/command.rb, line 279</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">description</span>
  <span class="ruby-keyword">nil</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-execute" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">execute</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Override to provide command handling.</p>

<p><a href="Command.html#attribute-i-options"><code>options</code></a> will be filled in with your parsed options, unparsed options will be left in <code>options[:args]</code>.</p>

<p>See also: <a href="Command.html#method-i-get_all_gem_names"><code>get_all_gem_names</code></a>, <a href="Command.html#method-i-get_one_gem_name"><code>get_one_gem_name</code></a>, <a href="Command.html#method-i-get_one_optional_argument"><code>get_one_optional_argument</code></a></p>

                              <div class="method-source-code" id="execute-source">
            <pre><span class="ruby-comment"># File rubygems/command.rb, line 149</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">execute</span>
  <span class="ruby-identifier">raise</span> <span class="ruby-constant">Gem</span><span class="ruby-operator">::</span><span class="ruby-constant">Exception</span>, <span class="ruby-string">&quot;generic command has no actions&quot;</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-get_all_gem_names" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">get_all_gem_names</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Get all gem names from the command line.</p>

                              <div class="method-source-code" id="get_all_gem_names-source">
            <pre><span class="ruby-comment"># File rubygems/command.rb, line 185</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">get_all_gem_names</span>
  <span class="ruby-identifier">args</span> = <span class="ruby-identifier">options</span>[<span class="ruby-value">:args</span>]

  <span class="ruby-keyword">if</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">empty?</span>
    <span class="ruby-identifier">raise</span> <span class="ruby-constant">Gem</span><span class="ruby-operator">::</span><span class="ruby-constant">CommandLineError</span>,
          <span class="ruby-string">&quot;Please specify at least one gem name (e.g. gem build GEMNAME)&quot;</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">args</span>.<span class="ruby-identifier">select</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">arg</span><span class="ruby-operator">|</span> <span class="ruby-identifier">arg</span> <span class="ruby-operator">!~</span> <span class="ruby-regexp">/^-/</span> }
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-get_all_gem_names_and_versions" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">get_all_gem_names_and_versions</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Get all [gem, version] from the command line.</p>

<p>An argument in the form gem:ver is pull apart into the gen name and version, respectively.</p>

                              <div class="method-source-code" id="get_all_gem_names_and_versions-source">
            <pre><span class="ruby-comment"># File rubygems/command.rb, line 201</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">get_all_gem_names_and_versions</span>
  <span class="ruby-identifier">get_all_gem_names</span>.<span class="ruby-identifier">map</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">name</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">extract_gem_name_and_version</span>(<span class="ruby-identifier">name</span>)
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-get_one_gem_name" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">get_one_gem_name</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Get a single gem name from the command line.  Fail if there is no gem name or if there is more than one gem name given.</p>

                              <div class="method-source-code" id="get_one_gem_name-source">
            <pre><span class="ruby-comment"># File rubygems/command.rb, line 219</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">get_one_gem_name</span>
  <span class="ruby-identifier">args</span> = <span class="ruby-identifier">options</span>[<span class="ruby-value">:args</span>]

  <span class="ruby-keyword">if</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">empty?</span>
    <span class="ruby-identifier">raise</span> <span class="ruby-constant">Gem</span><span class="ruby-operator">::</span><span class="ruby-constant">CommandLineError</span>,
          <span class="ruby-string">&quot;Please specify a gem name on the command line (e.g. gem build GEMNAME)&quot;</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-keyword">if</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">&gt;</span> <span class="ruby-value">1</span>
    <span class="ruby-identifier">raise</span> <span class="ruby-constant">Gem</span><span class="ruby-operator">::</span><span class="ruby-constant">CommandLineError</span>,
          <span class="ruby-node">&quot;Too many gem names (#{args.join(&quot;, &quot;)}); please specify only one&quot;</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">args</span>.<span class="ruby-identifier">first</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-get_one_optional_argument" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">get_one_optional_argument</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Get a single optional argument from the command line.  If more than one argument is given, return only the first. Return nil if none are given.</p>

                              <div class="method-source-code" id="get_one_optional_argument-source">
            <pre><span class="ruby-comment"># File rubygems/command.rb, line 239</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">get_one_optional_argument</span>
  <span class="ruby-identifier">args</span> = <span class="ruby-identifier">options</span>[<span class="ruby-value">:args</span>] <span class="ruby-operator">||</span> []
  <span class="ruby-identifier">args</span>.<span class="ruby-identifier">first</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-handle_options" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">handle_options</span><span
                                class="method-args">(args)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Handle the given list of arguments by parsing them and recording the results.</p>

                              <div class="method-source-code" id="handle_options-source">
            <pre><span class="ruby-comment"># File rubygems/command.rb, line 440</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">handle_options</span>(<span class="ruby-identifier">args</span>)
  <span class="ruby-identifier">args</span> = <span class="ruby-identifier">add_extra_args</span>(<span class="ruby-identifier">args</span>)
  <span class="ruby-identifier">check_deprecated_options</span>(<span class="ruby-identifier">args</span>)
  <span class="ruby-ivar">@options</span> = <span class="ruby-constant">Marshal</span>.<span class="ruby-identifier">load</span> <span class="ruby-constant">Marshal</span>.<span class="ruby-identifier">dump</span> <span class="ruby-ivar">@defaults</span> <span class="ruby-comment"># deep copy</span>
  <span class="ruby-identifier">parser</span>.<span class="ruby-identifier">parse!</span>(<span class="ruby-identifier">args</span>)
  <span class="ruby-ivar">@options</span>[<span class="ruby-value">:args</span>] = <span class="ruby-identifier">args</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-handles-3F" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">handles?</span><span
                                class="method-args">(args)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>True if the command handles the given argument list.</p>

                              <div class="method-source-code" id="handles-3F-source">
            <pre><span class="ruby-comment"># File rubygems/command.rb, line 429</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">handles?</span>(<span class="ruby-identifier">args</span>)
  <span class="ruby-identifier">parser</span>.<span class="ruby-identifier">parse!</span>(<span class="ruby-identifier">args</span>.<span class="ruby-identifier">dup</span>)
  <span class="ruby-keyword">true</span>
<span class="ruby-keyword">rescue</span> <span class="ruby-constant">StandardError</span>
  <span class="ruby-keyword">false</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-invoke" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">invoke</span><span
                                class="method-args">(*args)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Invoke the command with the given list of arguments.</p>

                              <div class="method-source-code" id="invoke-source">
            <pre><span class="ruby-comment"># File rubygems/command.rb, line 303</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">invoke</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
  <span class="ruby-identifier">invoke_with_build_args</span> <span class="ruby-identifier">args</span>, <span class="ruby-keyword">nil</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-invoke_with_build_args" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">invoke_with_build_args</span><span
                                class="method-args">(args, build_args)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Invoke the command with the given list of normal arguments and additional build arguments.</p>

                              <div class="method-source-code" id="invoke_with_build_args-source">
            <pre><span class="ruby-comment"># File rubygems/command.rb, line 311</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">invoke_with_build_args</span>(<span class="ruby-identifier">args</span>, <span class="ruby-identifier">build_args</span>)
  <span class="ruby-identifier">handle_options</span> <span class="ruby-identifier">args</span>

  <span class="ruby-identifier">options</span>[<span class="ruby-value">:build_args</span>] = <span class="ruby-identifier">build_args</span>

  <span class="ruby-keyword">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-value">:silent</span>]
    <span class="ruby-identifier">old_ui</span> = <span class="ruby-identifier">ui</span>
    <span class="ruby-keyword">self</span>.<span class="ruby-identifier">ui</span> = <span class="ruby-identifier">ui</span> = <span class="ruby-constant">Gem</span><span class="ruby-operator">::</span><span class="ruby-constant">SilentUI</span>.<span class="ruby-identifier">new</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-keyword">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-value">:help</span>]
    <span class="ruby-identifier">show_help</span>
  <span class="ruby-keyword">elsif</span> <span class="ruby-ivar">@when_invoked</span>
    <span class="ruby-ivar">@when_invoked</span>.<span class="ruby-identifier">call</span> <span class="ruby-identifier">options</span>
  <span class="ruby-keyword">else</span>
    <span class="ruby-identifier">execute</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">ensure</span>
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">ui</span>
    <span class="ruby-keyword">self</span>.<span class="ruby-identifier">ui</span> = <span class="ruby-identifier">old_ui</span>
    <span class="ruby-identifier">ui</span>.<span class="ruby-identifier">close</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-merge_options" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">merge_options</span><span
                                class="method-args">(new_options)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Merge a set of command options with the set of default options (without modifying the default option hash).</p>

                              <div class="method-source-code" id="merge_options-source">
            <pre><span class="ruby-comment"># File rubygems/command.rb, line 421</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">merge_options</span>(<span class="ruby-identifier">new_options</span>)
  <span class="ruby-ivar">@options</span> = <span class="ruby-ivar">@defaults</span>.<span class="ruby-identifier">clone</span>
  <span class="ruby-identifier">new_options</span>.<span class="ruby-identifier">each</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">k</span>,<span class="ruby-identifier">v</span><span class="ruby-operator">|</span> <span class="ruby-ivar">@options</span>[<span class="ruby-identifier">k</span>] = <span class="ruby-identifier">v</span> }
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-remove_option" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">remove_option</span><span
                                class="method-args">(name)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Remove previously defined command-line argument <code>name</code>.</p>

                              <div class="method-source-code" id="remove_option-source">
            <pre><span class="ruby-comment"># File rubygems/command.rb, line 369</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">remove_option</span>(<span class="ruby-identifier">name</span>)
  <span class="ruby-ivar">@option_groups</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">_</span>, <span class="ruby-identifier">option_list</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">option_list</span>.<span class="ruby-identifier">reject!</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">args</span>, <span class="ruby-identifier">_</span><span class="ruby-operator">|</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">any?</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">x</span><span class="ruby-operator">|</span> <span class="ruby-identifier">x</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">String</span>) <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">x</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp">/^#{name}/</span> } }
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-show_help" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">show_help</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Display the help message for the command.</p>

                              <div class="method-source-code" id="show_help-source">
            <pre><span class="ruby-comment"># File rubygems/command.rb, line 295</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">show_help</span>
  <span class="ruby-identifier">parser</span>.<span class="ruby-identifier">program_name</span> = <span class="ruby-identifier">usage</span>
  <span class="ruby-identifier">say</span> <span class="ruby-identifier">parser</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-show_lookup_failure" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">show_lookup_failure</span><span
                                class="method-args">(gem_name, version, errors, suppress_suggestions = false, required_by = nil)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Display to the user that a gem couldn’t be found and reasons why</p>

                              <div class="method-source-code" id="show_lookup_failure-source">
            <pre><span class="ruby-comment"># File rubygems/command.rb, line 157</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">show_lookup_failure</span>(<span class="ruby-identifier">gem_name</span>, <span class="ruby-identifier">version</span>, <span class="ruby-identifier">errors</span>, <span class="ruby-identifier">suppress_suggestions</span> = <span class="ruby-keyword">false</span>, <span class="ruby-identifier">required_by</span> = <span class="ruby-keyword">nil</span>)
  <span class="ruby-identifier">gem</span> = <span class="ruby-node">&quot;&#39;#{gem_name}&#39; (#{version})&quot;</span>
  <span class="ruby-identifier">msg</span> = <span class="ruby-constant">String</span>.<span class="ruby-identifier">new</span> <span class="ruby-node">&quot;Could not find a valid gem #{gem}&quot;</span>

  <span class="ruby-keyword">if</span> <span class="ruby-identifier">errors</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-operator">!</span><span class="ruby-identifier">errors</span>.<span class="ruby-identifier">empty?</span>
    <span class="ruby-identifier">msg</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-string">&quot;, here is why:\n&quot;</span>
    <span class="ruby-identifier">errors</span>.<span class="ruby-identifier">each</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">x</span><span class="ruby-operator">|</span> <span class="ruby-identifier">msg</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-node">&quot;          #{x.wordy}\n&quot;</span> }
  <span class="ruby-keyword">else</span>
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">required_by</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">gem</span> <span class="ruby-operator">!=</span> <span class="ruby-identifier">required_by</span>
      <span class="ruby-identifier">msg</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-node">&quot; (required by #{required_by}) in any repository&quot;</span>
    <span class="ruby-keyword">else</span>
      <span class="ruby-identifier">msg</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-string">&quot; in any repository&quot;</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">alert_error</span> <span class="ruby-identifier">msg</span>

  <span class="ruby-keyword">unless</span> <span class="ruby-identifier">suppress_suggestions</span>
    <span class="ruby-identifier">suggestions</span> = <span class="ruby-constant">Gem</span><span class="ruby-operator">::</span><span class="ruby-constant">SpecFetcher</span>.<span class="ruby-identifier">fetcher</span>.<span class="ruby-identifier">suggest_gems_from_name</span>(<span class="ruby-identifier">gem_name</span>, <span class="ruby-value">:latest</span>, <span class="ruby-value">10</span>)
    <span class="ruby-keyword">unless</span> <span class="ruby-identifier">suggestions</span>.<span class="ruby-identifier">empty?</span>
      <span class="ruby-identifier">alert_error</span> <span class="ruby-node">&quot;Possible alternatives: #{suggestions.join(&quot;, &quot;)}&quot;</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-usage" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">usage</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Override to display the usage for an individual gem command.</p>

<p>The text “[options]” is automatically appended to the usage text.</p>

                              <div class="method-source-code" id="usage-source">
            <pre><span class="ruby-comment"># File rubygems/command.rb, line 288</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">usage</span>
  <span class="ruby-identifier">program_name</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-when_invoked" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">when_invoked</span><span
                                class="method-args">(&amp;block)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Call the given block when invoked.</p>

<p>Normal command invocations just executes the <code>execute</code> method of the command.  Specifying an invocation block allows the test methods to override the normal action of a command to determine that it has been invoked correctly.</p>

                              <div class="method-source-code" id="when_invoked-source">
            <pre><span class="ruby-comment"># File rubygems/command.rb, line 343</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">when_invoked</span>(<span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
  <span class="ruby-ivar">@when_invoked</span> = <span class="ruby-identifier">block</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                          </section>

                <section id="private-instance-5Buntitled-5D-method-details" class="method-section">
                <header>
                <h3>Private Instance Methods</h3>
                </header>

                  <div id="method-i-add_parser_run_info" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">add_parser_run_info</span><span
                                class="method-args">(title, content)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Adds a section with <code>title</code> and <code>content</code> to the parser help view.  Used for adding command arguments and default arguments.</p>

                              <div class="method-source-code" id="add_parser_run_info-source">
            <pre><span class="ruby-comment"># File rubygems/command.rb, line 510</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">add_parser_run_info</span>(<span class="ruby-identifier">title</span>, <span class="ruby-identifier">content</span>)
  <span class="ruby-keyword">return</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">content</span>.<span class="ruby-identifier">empty?</span>

  <span class="ruby-ivar">@parser</span>.<span class="ruby-identifier">separator</span> <span class="ruby-keyword">nil</span>
  <span class="ruby-ivar">@parser</span>.<span class="ruby-identifier">separator</span> <span class="ruby-node">&quot;  #{title}:&quot;</span>
  <span class="ruby-identifier">content</span>.<span class="ruby-identifier">split</span>(<span class="ruby-regexp">/\n/</span>).<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">line</span><span class="ruby-operator">|</span>
    <span class="ruby-ivar">@parser</span>.<span class="ruby-identifier">separator</span> <span class="ruby-node">&quot;    #{line}&quot;</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-configure_options" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">configure_options</span><span
                                class="method-args">(header, option_list)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="configure_options-source">
            <pre><span class="ruby-comment"># File rubygems/command.rb, line 556</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">configure_options</span>(<span class="ruby-identifier">header</span>, <span class="ruby-identifier">option_list</span>)
  <span class="ruby-keyword">return</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">option_list</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">option_list</span>.<span class="ruby-identifier">empty?</span>

  <span class="ruby-identifier">header</span> = <span class="ruby-identifier">header</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">empty?</span> <span class="ruby-operator">?</span> <span class="ruby-string">&quot;&quot;</span> <span class="ruby-operator">:</span> <span class="ruby-node">&quot;#{header} &quot;</span>
  <span class="ruby-ivar">@parser</span>.<span class="ruby-identifier">separator</span> <span class="ruby-node">&quot;  #{header}Options:&quot;</span>

  <span class="ruby-identifier">option_list</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">args</span>, <span class="ruby-identifier">handler</span><span class="ruby-operator">|</span>
    <span class="ruby-ivar">@parser</span>.<span class="ruby-identifier">on</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">value</span><span class="ruby-operator">|</span>
      <span class="ruby-identifier">handler</span>.<span class="ruby-identifier">call</span>(<span class="ruby-identifier">value</span>, <span class="ruby-ivar">@options</span>)
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-ivar">@parser</span>.<span class="ruby-identifier">separator</span> <span class="ruby-string">&quot;&quot;</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-create_option_parser" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">create_option_parser</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Creates an option parser and fills it in with the help info for the command.</p>

                              <div class="method-source-code" id="create_option_parser-source">
            <pre><span class="ruby-comment"># File rubygems/command.rb, line 542</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">create_option_parser</span>
  <span class="ruby-ivar">@parser</span> = <span class="ruby-constant">Gem</span><span class="ruby-operator">::</span><span class="ruby-constant">OptionParser</span>.<span class="ruby-identifier">new</span>

  <span class="ruby-identifier">add_parser_options</span>

  <span class="ruby-ivar">@parser</span>.<span class="ruby-identifier">separator</span> <span class="ruby-keyword">nil</span>
  <span class="ruby-identifier">configure_options</span> <span class="ruby-string">&quot;Common&quot;</span>, <span class="ruby-constant">Gem</span><span class="ruby-operator">::</span><span class="ruby-constant">Command</span>.<span class="ruby-identifier">common_options</span>

  <span class="ruby-identifier">add_parser_run_info</span> <span class="ruby-string">&quot;Arguments&quot;</span>, <span class="ruby-identifier">arguments</span>
  <span class="ruby-identifier">add_parser_summary</span>
  <span class="ruby-identifier">add_parser_description</span>
  <span class="ruby-identifier">add_parser_run_info</span> <span class="ruby-string">&quot;Defaults&quot;</span>, <span class="ruby-identifier">defaults_str</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-option_is_deprecated-3F" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">option_is_deprecated?</span><span
                                class="method-args">(option)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="option_is_deprecated-3F-source">
            <pre><span class="ruby-comment"># File rubygems/command.rb, line 475</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">option_is_deprecated?</span>(<span class="ruby-identifier">option</span>)
  <span class="ruby-ivar">@deprecated_options</span>[<span class="ruby-identifier">command</span>].<span class="ruby-identifier">key?</span>(<span class="ruby-identifier">option</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-parser" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">parser</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Create on demand parser.</p>

                              <div class="method-source-code" id="parser-source">
            <pre><span class="ruby-comment"># File rubygems/command.rb, line 533</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">parser</span>
  <span class="ruby-identifier">create_option_parser</span> <span class="ruby-keyword">if</span> <span class="ruby-ivar">@parser</span>.<span class="ruby-identifier">nil?</span>
  <span class="ruby-ivar">@parser</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-wrap" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">wrap</span><span
                                class="method-args">(text, width)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Wraps <code>text</code> to <code>width</code></p>

                              <div class="method-source-code" id="wrap-source">
            <pre><span class="ruby-comment"># File rubygems/command.rb, line 574</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">wrap</span>(<span class="ruby-identifier">text</span>, <span class="ruby-identifier">width</span>) <span class="ruby-comment"># :doc:</span>
  <span class="ruby-identifier">text</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp">/(.{1,#{width}})( +|$\n?)|(.{1,#{width}})/</span>, <span class="ruby-string">&quot;\\1\\3\n&quot;</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                          </section>

              </section>
              </main>



            </div>  <!--  class='wrapper hdiv' -->


<footer id="validator-badges" role="contentinfo">
<p><a href="https://validator.w3.org/check/referer">Validate</a></p>
<p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.4.0.</p>
<p>Based on <a href="https://github.com/ged/darkfish/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.</p>

  
    <p><p><a href="https://ruby-doc.org">Ruby-doc.org</a> is provided by <a href="https://jamesbritt.com">James Britt</a> and <a href="https://neurogami.com">Neurogami</a>. </p><p><a href="https://jamesbritt.bandcamp.com/">Hack your world.  Feed your head.  Live curious</a>.</p>
</p>
  
  </footer>

<script type="text/javascript">


  let ads  = $("#carbonads-container").children().detach();


  function swapMode() {
    var cookieName = 'darkmode';
    var cssDarkmode = Cookies.get(cookieName);
    console.log("***** swapMode! " + cssDarkmode + " *****");


    if (cssDarkmode == "true") {
      console.log("We have dark mode, set the css to light ...");
      $('#rdoccss').attr("href", defaultModeCssHref);
      $('#cssSelect').text("Dark mode");
      cssDarkmode = "false";
      console.log("swapMode! Now set cookie to " + cssDarkmode);
      Cookies.set(cookieName, cssDarkmode);

    } else {
      console.log("We not have dark mode, set the css to dark ...");
      $('#rdoccss').attr("href", darkModeCsseHref);
      $('#cssSelect').text("Light mode");
      cssDarkmode = "true";
      console.log("swapMode! Now set cookie to " + cssDarkmode);
      Cookies.set(cookieName, cssDarkmode);

    }

    console.log("  --------------- ");
  }


const vueCssApp = new Vue({
el: '#menubar',
data: {
isDark: false
},
methods: {
toggleClass: function(event){
this.isDark = !this.isDark;
}
}
})

const vueApp = new Vue({
el: '#vapp',
data: { 
isOpen: true
},

mounted() {
this.handleResize();
this.manage_mob_classes();
window.addEventListener('resize', this.handleResize)
//this.isOpen !=  (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
},
destroyed() {
window.removeEventListener('resize', this.handleResize)
},
created() {
//manage_mob_classes();
},

methods : {
isMobile() {
  return (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
},

  handleResize() {
    if (!this.isMobile()) {
      this.isOpen = window.innerWidth > 800;
    }
  },

  manage_mob_classes() {
    if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
      $("nav").addClass("mob_nav");
      $("main").addClass("mob_main");
      $("#extraz").addClass("mob_extraz");
      $("#carbonads-container").addClass("mob_carbonads-container");
      this.isOpen  = false;
    } else {
      $("nav").removeClass("mob_nav") 
        $("main").removeClass("mob_main");
      $("#extraz").removeClass("mob_extraz");
      $("#carbonads-container").removeClass("mob_carbonads-container");
      this.isOpen  = true;
    }
  },

  toggleNav() {
    this.isOpen =! this.isOpen ;
    // alert("Toggle nav!");
    console.log("toggleNav() click: " + this.isOpen );
  }
}
})

$("#carbonads-container").append(ads);


$(function() {

    var darkmode = Cookies.get("darkmode");
    console.log("Document ready: " + darkmode);

    if ( darkmode  == "true" ) {
      $('#cssSelect').text("Light mode");
    } else {
      $('#cssSelect').text("Dark mode");
     }

    $('body').css('display','block');
    });

</script>

    
  </body> 
</html>

